package com.holly.unit.bpmn.designer.model;

import cn.hutool.core.collection.ListUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Objects;

/**
 * 类描述: 子节点的属性
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/12 8:55
 */
@Getter
@Setter
@Accessors(chain = true)
public class ChildProperties {

    /**节点标题*/
    private String title;

    /**审批人*/
    private List<TreeSelectModel> approvers;

    /**审批角色*/
    private List<TreeSelectModel> approverRoles;

    /**办理类型*/
    private String assigneeType;

    /**多用户*/
    private String optionalMultiUser;

    /**EL表达式*/
    private String expression;

    /**表单字段控制*/
    private List<FormColControl> formColControls;

    /**流程办理按钮控制 */
    private List<BtnControl> btnControls;

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private ChildProperties properties;

        private Builder() {
            this.properties = new ChildProperties();
        }

        public Builder title(final String title) {
            if (Objects.nonNull(title)) {
                this.properties.setTitle(title);
            }
            return this;
        }

        public Builder assigneeType(final String assigneeType) {
            if (Objects.nonNull(assigneeType)) {
                this.properties.setAssigneeType(assigneeType);
            }
            return this;
        }

        public Builder optionalMultiUser(final String optionalMultiUser) {
            if (Objects.nonNull(optionalMultiUser)) {
                this.properties.setOptionalMultiUser(optionalMultiUser);
            }
            return this;
        }



        public Builder approvers(final List<TreeSelectModel> approvers) {
            if (Objects.nonNull(approvers) && approvers.size()>0) {
                this.properties.setApprovers(approvers);
            }
            return this;
        }

        public Builder approvers(final TreeSelectModel approver) {
            if (Objects.nonNull(approver)) {
                this.properties.setApprovers(ListUtil.of(approver));
            }
            return this;
        }

        public Builder roles(final List<TreeSelectModel> approverRoles) {
            if (Objects.nonNull(approverRoles) && approverRoles.size()>0) {
                this.properties.setApproverRoles(approverRoles);
            }
            return this;
        }

        public Builder roles(final TreeSelectModel approverRoles) {
            if (Objects.nonNull(approverRoles)) {
                this.properties.setApproverRoles(ListUtil.of(approverRoles));
            }
            return this;
        }

        public Builder columns(final List<FormColControl> formColControls) {
            if (Objects.nonNull(formColControls) && formColControls.size()>0) {
                this.properties.setFormColControls(formColControls);
            }
            return this;
        }

        public Builder columns(final FormColControl formColControl) {
            if (Objects.nonNull(formColControl)) {
                this.properties.setFormColControls(ListUtil.of(formColControl));
            }
            return this;
        }

        public Builder btns(final List<BtnControl> btnControls) {
            if (Objects.nonNull(btnControls) && btnControls.size()>0) {
                this.properties.setBtnControls(btnControls);
            }
            return this;
        }

        public Builder btns(final BtnControl btnControl) {
            if (Objects.nonNull(btnControl)) {
                this.properties.setBtnControls(ListUtil.of(btnControl));
            }
            return this;
        }

        public ChildProperties build() {
            return this.properties;
        }
    }
}
